<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
<script type="text/javascript" src="js/jquery-1.8.3.js"></script>
<script type="text/javascript">
	function save() {
		var name=$("#name").val();
		var author=$("#author").val();
		var time=$("#time").val();
		var type=$("#type").val();
		if (name=="" || author=="") {
			alert("图书名称和作者不能为空");
			return false;
		}
		if (time=="" || !(isNaN(time) && !isNaN(Date.parse(time)))) {
			alert("日期格式错误");
			return false;
		}
		if (type==0) {
			alert("请选择图书分类");
			return false;
		}
		return true;
	}
</script>
</head>
<body>
	<div>
	<h3>新增图书信息</h3>
	<form action="AddServlet" method="get" onsubmit="return save()">
		图书名称:<input type="text" name="name" id="name"><br>
		图书作者:<input type="text" name="author" id="author"><br>
		购买日期:<input type="text" name="time" id="time"><span>yyyy-MM-dd格式</span><br>
		图书类别:<select name="type" id="type">
				<option value="0">选择所属分类:</option>
				<option value="1">计算机/软件</option>
				<option value="2">小说/文稿</option>
				<option value="3">杂项</option>
		</select>
		<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
		<input type="submit" value="增加图书">
		</form>
	</div>
</body>
</html>